package com.hutao.sso.controller.user;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.hutao.sso.pojo.user.Users;
import com.hutao.sso.service.user.UsersService;
import com.hutao.sso.util.Page;

@RequestMapping("/users")
@Controller
public class UserController {
	
	@Autowired
	private UsersService usersService;
	
	
	@PostMapping("/findUserListPage")
	@ResponseBody
	public Map<String, Object> findUserListPage(@RequestParam(value = "page", defaultValue = "1") int currentPage,
			HttpServletRequest request, HttpSession session) {
		Users user = (Users)session.getAttribute("current_user");
		
		Map<String, Object> results = new HashMap<>();
		Map<String, Object> params = new HashMap<>();
		Page<Users> page = new Page<>();
		page.setPageSize(20);
		page.setCurrentPage(currentPage);
		params.put("page", page);
		params.put("loginName", request.getParameter("loginName"));
		if(null != user) {
			params.put("medicalMainstayId", user.getMedicalMainstayId());
		}else {
			params.put("medicalMainstayId", "");
		}
		
		List<Users> usersList = usersService.findUserListPage(params);
		
		return null;
	}
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
}
